﻿# import cv2
# import pytesseract

# img = cv2.imread(r'C:\Users\MaxShannon\source\repos\HandleTest\SysHandle\record\game1\1\0_1.png')
# img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
# pytesseract.pytesseract.tesseract_cmd = (
#             r"C:\Program Files\Tesseract-OCR\tesseract.exe"
#         )

# recognized_text = pytesseract.image_to_string(
#             img, config=r"--oem 3 --psm 6 outputbase digits"
#         )
# print(recognized_text)


import pygetwindow
import time
from win32_api import Win32Api
from operate_controller import OperateController
from player import Player
from board_2048 import Board2048
from recognize import Recognize

win32Api = Win32Api()
handle = win32Api.open_2048_window()

operate_controller = OperateController(handle)

recognize = Recognize(pygetwindow.getWindowsWithTitle("新2048")[0])
# recognize.recognize_board()

game_board = Board2048()

# v = recognize.recognize_board_row_column(3, 1)
# game_board.add_new_tile_i_j(3, 1, v)

for i in range(4):
    for j in range(4):
        v = recognize.recognize_board_row_column(i, j)
        game_board.add_new_tile_i_j(i, j, v)


game_board.display()

# player = Player(operate_controller)

# player.play(10)  # 运行 10 秒


# im = pyautogui.screenshot()
# color = im.getpixel((1000, 500))
# print(color)


# controller = OperateController()
# # 调用 move_forward 方法
# controller.move_up()  # 输出: Moving forward
